
public class RulesEngineExtended extends RulesEngine {
	
	
	
	
	
	private double s_neighborSeedingProb;
	

	/**
	 * decide the state of the cell according to its neighbors
	 * 
	 * @param currentCell
	 * @param upCell
	 * @param downCell
	 * @param rightCell
	 * @param leftCell
	 * @param p_growNewPlantProb
	 * @param g_combustibilityProb
	 * @param f_lightningStrikeProb
	 * @param s_neighborSeedingProb
	 */
	public void decideCellState(TreeCell currentCell, TreeCell upCell,
			TreeCell downCell, TreeCell rightCell, TreeCell leftCell,
			double p_growNewPlantProb, double g_combustibilityProb,
			double f_lightningStrikeProb,double s_neighborSeedingProb) {
		this.currentCell= currentCell;
		this.upCell = upCell;
		this.downCell= downCell;
		this.rightCell=rightCell;
		this.leftCell=leftCell;
		
		this.p_growNewPlantProb=p_growNewPlantProb;
		this.g_combustibilityProb=g_combustibilityProb;
		this.s_neighborSeedingProb=s_neighborSeedingProb;
		this.f_lightningStrikeProb=f_lightningStrikeProb;
		
		
		switch (currentCell.cellState) {
		case TreeCell.EMPTY_CELL:
			handleEmptyCell();
			break;
		case TreeCell.TREE_CELL:
			handleTreeCell();
			break;
		case TreeCell.BURNING_TREE_CELL:
			handleBurningCell();
			break;	
		}
	}


	protected void handleEmptyCell() {
		if (decideWithProbability(p_growNewPlantProb) )
		  currentCell.cellState=TreeCell.TREE_CELL;
		else
		   if ((upCell.cellState==TreeCell.TREE_CELL||
					downCell.cellState==TreeCell.TREE_CELL||
					rightCell.cellState==TreeCell.TREE_CELL||	
					leftCell.cellState==TreeCell.TREE_CELL) &&
					decideWithProbability(s_neighborSeedingProb))
			   currentCell.cellState=TreeCell.TREE_CELL;
	}


}
